package com.ruoyi.mining.domain;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;

/**
 * 小升初考试登记对象 mn_exam
 *
 * @author mining
 * @date 2025-05-23
 */
@Data
@ToString
@ApiModel(value = "小升初考试登记对象", description = "小升初考试登记对象")
public class Exam  {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "报考学校")
    @Excel(name = "报考学校")
    private String applySchool;

    @ApiModelProperty(value = "报名方式")
    @Excel(name = "报名方式")
    private String channel;

    @ApiModelProperty(value = "学生姓名")
    @Excel(name = "学生姓名")
    private String name;

    @ApiModelProperty(value = "在读学校")
    @Excel(name = "在读学校")
    private String primarySchool;

    @ApiModelProperty(value = "学校所在区")
    @Excel(name = "学校所在区")
    private String schoolArea;

    @ApiModelProperty(value = "家庭住址")
    @Excel(name = "家庭住址")
    private String addArea;

    @ApiModelProperty(value = "身份证号码")
    @Excel(name = "身份证号码")
    private String idCard;

    @ApiModelProperty(value = "联系电话")
    @Excel(name = "联系电话")
    private String phone1;

    @ApiModelProperty(value = "联系电话2")
    @Excel(name = "联系电话2")
    private String phone2;

    @ApiModelProperty(value = "性别")
    @Excel(name = "性别")
    private String gender;

    @ApiModelProperty(value = "上岸学校")
    @Excel(name = "上岸学校")
    private String landSchool;

    @ApiModelProperty(value = "报考时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "报考时间", width = 30, dateFormat = "yyyy-MM-dd")
    private String createDate;

    @ApiModelProperty(value = "年级")
    @Excel(name = "年级")
    private String grade;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "是否参加")
    @Excel(name = "是否参加")
    private String attend;

    @ApiModelProperty(value = "考试状态")
    @Excel(name = "考试状态")
    private String status;

    @ApiModelProperty(value = "考号")
    @Excel(name = "考号")
    private String examNum;

    /** 用户ID关联 */
    @Excel(name = "用户ID关联")
    @ApiModelProperty(value = "用户ID关联")
    private Long userId;

    @ApiModelProperty(value = "是否删除")
    private boolean viewFlag;

    @ApiModelProperty(value = "考试时间", example = "2020-01-01", dataType = "string")
    private String examDate;

    @ApiModelProperty(value = "考试地址")
    private String examAddr;
//    exam_date

    @ApiModelProperty(value = "推荐老师")
    private String referrer;


    public String getGender() {
        if (idCard != null && !idCard.isEmpty()) {
            // 身份证长度应为18位（新身份证）或15位（旧身份证）
            if (idCard.length() == 18) {
                // 第17位是性别位（索引16，因为从0开始）
                char genderCode = idCard.charAt(16);
                return (genderCode % 2 == 1) ? "男" : "女";
            } else if (idCard.length() == 15) {
                // 15位身份证，第15位是性别位（索引14）
                char genderCode = idCard.charAt(14);
                return (genderCode % 2 == 1) ? "男" : "女";
            }
        }
        return gender; // 如果身份证为空或格式不正确，返回原来的gender值
    }
}
